#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main()
{
	for (int i = 1; i <= 100000; i++)
	{
		int count = 0;
		int t = i;
		while (t != 0)
		{
			t /= 10;
			count++;
		}
		int sum = 0,k=i;
		while (k != 0)
		{
			sum += pow(k % 10, count);
			k /= 10;
		}
		if (sum == i)
		{
			printf("%d ", i);
		}
	}
	return 0;
}